<template>
	<view class="group-product-block">
		<view class="group-product-bar">
			<image class="group-product-bar__tit" :src="'https://static.member.stourweb.cn/uniapp/static/images/' + 'group_team_title.png'" mode="aspectFit"></image>
			<view class="group-product-bar__txt">{{pintuan.title}}</view>
			<view class="group-product-bar__btn" @click="toPintuan">发起拼团</view>
		</view>
		<view class="group-product-list">
			<template v-for="(item, index) in pintuaning">
				<view class="group-product-list__item" :key="index" v-if="item.endtime * 1000 > now">
					<image class="group-product-list__item__hd" :src="item.member.litpic" mode="aspectFill"></image>
					<view class="group-product-list__item__bd">
						<view class="sell" v-if="parseInt(pintuan.people_number) > parseInt(item.count)">还差{{parseInt(pintuan.people_number) - parseInt(item.count)}}人成团</view>
						<view class="date">仅剩<st-countdown :time="item.endtime*1000 - now" :now="now" :bgStyle="{color: '#fff', background: '#f71471'}"></st-countdown></view>
						<view class="user">团长：{{item.member.nickname}}</view>
					</view>
					<view class="group-product-list__item__fd">
						<view class="join" @click="toJointuan(item.id)">参与拼团</view>
						<view class="date">{{item.usedate}}出发</view>
					</view>
				</view>
			</template>
			
			
		</view>
	</view>
</template>

<script>
	import stCountdown from "./st-countdown.vue";
	export default {
		name: 'stGroupTeam',
		components: {
			stCountdown
		},
		props: {
			pintuaning: {
				type: Array,
				default: function(){return []}
			},
			pintuan: {
				type: Object,
				default: function(){return {}}
			},
		},
		data() {
			return {
				now : 0
			};
		},
		mounted() {
			this.now = (new Date()).getTime()
		},
		methods: {
			toPintuan(){
				this.$emit('toPintuan')
			},
			toJointuan(id){
				this.$emit('toJointuan', id)
			},
		}
	}
</script>

<style lang="scss">

	.group-product-block{
		
	}
	
	.group-product-bar{
		display: flex;
		align-items: center;
		padding: 30rpx 24rpx;
		position: relative;
		background-color: #fb2b6e;
		&__tit{
			width: 160rpx;
			height: 30rpx;
		}
		&__txt{
			color: #f82c7d;
			padding: 8rpx 20rpx;
			position: absolute;
			top: 50%;
			left: 200rpx;
			transform: scale(.5) translateY(-50%);
			transform-origin: left top;
			font-size: 40rpx;
			border-radius: 16rpx;
			background-color: #ffecf4;
			&:after{
				content: "";
				position: absolute;
				left: -20rpx;
				top: 24rpx;
				z-index: -1;
				display: inline-block;
				width: 0;
				height: 0;
				transform: rotate(49deg);
				border-top: 40rpx solid #ffecf4;
				border-left: 10rpx solid transparent;
				border-right: 20rpx solid transparent;
			}
		}
		&__btn{
			color: #fe2a60;
			padding: 8rpx 20rpx;
			position: absolute;
			top: 50%;
			right: 24rpx;
			border-radius: 60rpx;
			transform: scale(.5) translateY(-50%);
			transform-origin: right top;
			font-size: 40rpx;
			background-color: $uni-bg-color;
		}
	}
	
	.group-product-list{
		&__item{
			@include justifyspacec;
			padding: 36rpx 24rpx;
			position: relative;
			background-color:#fff4f7;
			&:after{
				@include line;
				left: 24rpx;
				right: 24rpx;
			}
			&__hd{
				flex: 0 0 auto;
				width: 100rpx;
				height: 100rpx;
			}
			&__bd{
				flex: 1 1 auto;
				padding: 0 20rpx;
				.sell{
					font-size: $uni-font-size-sm;
				}
				.date{
					color: #f85357;
					width: 200%;
					margin-top: -20rpx;
					transform: scale(.5);
					transform-origin: left bottom;
					font-size: 40rpx;
				}
				.user{
					color: $uni-text-color-grey;
					width: 200%;
					margin-top: -20rpx;
					transform: scale(.5);
					transform-origin: left bottom;
					font-size: 40rpx;
				}
			}
			&__fd{
				flex: 0 0 auto;
				width: 160rpx;
				.join{
					color: #ff3478;
					display: inline-block;
					padding: 12rpx 30rpx;
					font-size: $uni-font-size-sm;
					border-radius: 120rpx;
					background-color: #ffd7e4;
				}
				.date{
					color: $uni-text-color-grey;
					margin-top: -12rpx;
					white-space: nowrap;
					transform: scale(.5);
					transform-origin: left bottom;
					font-size: 40rpx;
					font-family: Arial, Helvetica, sans-serif;
				}
			}
		}
	}

</style>
